package com.example.myapplication.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;

import android.util.AttributeSet;
import android.view.View;

/**
 * 圆和线
 * 作者：李祥
 * 邮箱：499194689@qq.com
 */

public class TestView05 extends View{
    Paint paint=new Paint();
    int mH;
    int mW;
    public TestView05(Context context) {
        super(context);
    }

    public TestView05(Context context,  AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        mH=h;
        mW=w;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        // 将坐标系原点移动到画布正中心
        canvas.translate(mW/2,mH/2);

        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(2);
        canvas.drawCircle(0,0,150,paint);
        canvas.drawCircle(0,0,130,paint);
        for (int i=0;i<=36;i++){
            canvas.drawLine(0,150,0,130,paint);
            canvas.rotate(10);
        }
        for (int i=0;i<=10;i++){
            canvas.drawCircle(0,0,120,paint);
            canvas.scale(0.8f,0.8f);
        }
    }
}
